/*import _ from 'lodash'


export const orderBy = _.orderBy;
export const debounce = _.debounce;*/

export const deepClone = function(obj) {
    if (Array.isArray(obj)) {
        return obj.map(deepClone)
    } else if (obj && typeof obj === 'object') {
        var cloned = {}
        var keys = Object.keys(obj)
        for (var i = 0, l = keys.length; i < l; i++) {
            var key = keys[i]
            cloned[key] = deepClone(obj[key])
        }
        return cloned
    } else {
        return obj
    }
}

export const isFloat = function(n){
    var m = n.match(/^-?\d*(\.\d+)?$/);
    if(m){
        return !!m[1];
    }else{
        return false
    }
}

export const toFloat = function (val) {
    if(val){
        val = val.replace(/[^\d.]/g, '');

        val = (+val).toFixed(2)
    }
    return val
}

export const scrollDirect = function (fn) {
    var beforeScrollTop = document.body.scrollTop;
    fn = fn || function () {};
    window.addEventListener("scroll", function (event) {
        event = event || window.event;

        var afterScrollTop = document.body.scrollTop,
            delta = afterScrollTop - beforeScrollTop;
        beforeScrollTop = afterScrollTop;

        var scrollTop = $(this).scrollTop();
        var scrollHeight = $(document).height();
        var windowHeight = $(this).height();
        if (scrollTop + windowHeight > scrollHeight - 10) {  //滚动到底部执行事件
            fn('up');
            return;
        }
        if (afterScrollTop < 10 || afterScrollTop > $(document.body).height - 10) {
            fn('up');
        } else {
            if (Math.abs(delta) < 10) {
                return false;
            }
            fn(delta > 0 ? "down" : "up");
        }
    }, false);
}
